package com.baiintent;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	
	EditText e1,e2;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	public void Guicon(View v){
		
		e1=(EditText) findViewById(R.id.ed1);
		e2=(EditText) findViewById(R.id.ed2);
		int e11=Integer.parseInt(e1.getText().toString());
		int e12=Integer.parseInt(e2.getText().toString());
		Intent i = new Intent(this, MainActivity2.class);
		i.putExtra("jay", e11);
		i.putExtra("jay2", e12);
		this.startActivityForResult(i,50005 );
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		
		if(requestCode == 50005)
		{
			if(resultCode==this.RESULT_OK)
			{
				e1=(EditText) findViewById(R.id.ed1);
				e2=(EditText) findViewById(R.id.ed2);
				int e11=Integer.parseInt(e1.getText().toString());
				int e12=Integer.parseInt(e2.getText().toString());
				int trave=data.getIntExtra("jay3", -1);
				String lydo=data.getStringExtra("jay4");
				TextView t4=(TextView) findViewById(R.id.tx1);
				t4.setText("" +(e11+e12-trave));
				Toast.makeText(this,""+lydo, Toast.LENGTH_LONG).show();
			}
		}
		super.onActivityResult(requestCode, resultCode, data);
	}
	
}
